package br.ufms.odontologico.bo;

import java.io.Serializable;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.persistence.Query;

import br.ufms.odontologico.model.Dentista;
import br.ufms.odontologico.util.JpaUtils;
@ViewScoped
@ManagedBean
public class DentistaBO implements Serializable {
	@ManagedProperty("#{genericBO}")
	private GenericBO<Dentista> gbo;
	private static final long serialVersionUID = 4883078715204614819L;

	@SuppressWarnings("unchecked")
	public List<Dentista> listByNome(String nome) {
		Query qr = getGbo().getEm().createQuery("from Dentista where nome like ?");
		qr.setParameter(1, JpaUtils.likeAny(nome));
		Object obj = qr.getResultList();
		return (obj instanceof List<?>) ?((List<Dentista>) obj) :null;
	}

	public GenericBO<Dentista> getGbo() {
		return gbo;
	}

	public void setGbo(GenericBO<Dentista> gbo) {
		this.gbo = gbo;
	}
	
}
